package com.lanou3g.musicenjoy.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.lanou3g.musicenjoy.fragment.MineFragment;
import com.lanou3g.musicenjoy.fragment.MusicLibraryFragment;
import com.lanou3g.musicenjoy.fragment.MyFragment;
import com.lanou3g.musicenjoy.fragment.RankingFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 辛鑫 on 15/10/20.
 * MainFragment的适配器,加载title和title对应的Fragment
 */
public class MyPagerAdapter extends FragmentPagerAdapter {
    private String[] titles = {"我的", "乐库", "推荐", "排行"};
    //存储fragment类型
    private List<Fragment> datas;
    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setData(List<Fragment> datas) {
        this.datas = datas;
    }

    @Override
    public Fragment getItem(int position) {
        Log.i("lanou","---------38");
        return datas != null && datas.size() > 0 ? datas.get(position) : null;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
